package com.bwie.doctorclient.controller;

import com.bwie.common.core.domain.Result;
import com.bwie.doctorclient.domain.dto.AddDosageDTO;
import com.bwie.doctorclient.domain.po.DosagePO;
import com.bwie.doctorclient.domain.vo.PrescriptionVO;
import com.bwie.doctorclient.service.OldPrescriptionsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/oldPrescription")
public class OldPrescriptionsController {
    @Autowired
    private OldPrescriptionsService oldPrescriptionsService;

    /**
     * 医生查询历史处方列表
     * @return
     */
    @GetMapping("/getOldPrescriptions")
    public Result  getOldPrescriptions(){
        List<PrescriptionVO> list = oldPrescriptionsService.getOldPrescriptions();
        return Result.success(list);
    }

    /**
     * 设为常用处方
     * @param prescriptionId
     * @return
     */
    @PostMapping("/changeCommonlyPrescription/{prescriptionId}")
    public Result changeCommonlyPrescription(@PathVariable Long prescriptionId){
        oldPrescriptionsService.changeCommonlyPrescription(prescriptionId);
        return Result.success();
    }

    /**
     * 删除历史处方中药品用法用量
     * @param dosageId
     * @return
     */
    @DeleteMapping("/delDosage/{dosageId}")
    public Result delDosage(@PathVariable Long dosageId){
        oldPrescriptionsService.delDosage(dosageId);
        return Result.success();
    }

    /**
     * 编辑历史药品用法用量
     * @param
     * @return
     */
    @PutMapping("/updDosage")
    public Result updDosage(@RequestBody DosagePO dosagePO){
        oldPrescriptionsService.updDosage(dosagePO);
        return Result.success();
    }

    /**
     * 新增历史处方药品
     * @param
     * @return
     */
    @PostMapping("/addDosage")
    public Result addDosage(@RequestBody AddDosageDTO addDosageDTO){
        oldPrescriptionsService.addDosage(addDosageDTO);
        return Result.success();
    }
}
